/**
 * Created by Administrator on 2016/6/30 0030.
 */
import React from 'react';

var scope;
export default class ShipType extends React.Component{

    constructor(props){
        super(props);
        scope = this;
    };

    handleShipType(i,shipCode){
        scope.props.callbackShipType(i,shipCode);
    };

    render(){
        return (
            <div className="pay-part">
                <div className="part-head">配送方式</div>
                <ul className="type-box ship-type-box">
                    {scope.shipItem()}
                </ul>
            </div>
        );
    };

    shipItem(){
        var data = scope.props.data;
        var shipItems = '';
        if(data.ship_type && data.ship_type.length > 0){
            shipItems = data.ship_type.map(function (s,i) {
                var index = scope.props.data.ship_type_index;
                var checkedClass = '';
                if(index == i){
                    checkedClass = 'checked-label';
                }
                return (
                    <li key={s.ship_code + '_ship'}>
                        <div className="check-group">
                            <label className={"check-radio " + checkedClass} for={s.ship_code}
                                   onClick={scope.handleShipType.bind(this,i,s.ship_code)}></label>
                            <span className="big-text">{s.ship_conpany}</span>
                        </div>
                    </li>
                ) ;
            })
        }
        return shipItems;
    };
};